package vng.wcc.sonph.LauncherGenerator;

import android.content.Context;
/**
 * This class extends the standard ViewFlipper,
 * it contains some children, each of them is displayed as a screen 
 * @author sonph
 *
 */
public class LauncherView extends DragableSpace {

		
	
	private TabRowView tabRow = null;

	/**
	 * Create a LauncherView: ViewFlipper that contains several screens (LauncherScreenView)
	 * @param context
	 * @param data contains information about the items to be displayed (icon,title and intent to launch)
	 * @param formatter 
	 * @param numColsPerPage number of columns per row on each page
	 */
	public LauncherView(Context context,CellInfo[][] data,Formatter formatter,TabRowView tabRow, int numColsPerPage) {
		super(context);
		this.tabRow = tabRow;
		for(int i = 0; i < data.length ; i++) {
			this.addView(new LauncherScreenView(this.getContext(), data[i], formatter, numColsPerPage),
					LauncherView.LayoutParams.FILL_PARENT,
					LauncherView.LayoutParams.FILL_PARENT);			
		}
	}
	public LauncherView(Context context,CellInfo[][] data,Formatter formatter, int numColsPerPage) {
		super(context);		
		for(int i = 0; i < data.length ; i++) {
			this.addView(new LauncherScreenView(this.getContext(), data[i], formatter, numColsPerPage),
					LauncherView.LayoutParams.FILL_PARENT,
					LauncherView.LayoutParams.FILL_PARENT);			
		}
	}
	
	@Override
	public void snapToScreen(int whichScreen) {	
		int currentScreen = this.getCurrentScreenId();
		super.snapToScreen(whichScreen);
		if ( this.tabRow != null ) {
			tabRow.changeHighLight(currentScreen, whichScreen);
		}		
	}


}
